/*
 *  Copyright (c) 2022 ZhuHai Jieli Technology Co.,Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef _RDEC_H_
#define _RDEC_H_

#define DEVICE_EVENT_FROM_RDEC        (('R' << 24) | ('D' << 16) | ('E' << 8) | '\0')

enum rdec_index {
    RDEC0,
    RDEC1,
    RDEC2,
};

struct rdec_device {
    enum rdec_index index;
    u8 sin_port0;     // 采样信号端口0
    u8 sin_port1;     // 采样信号端口1
    u8 key_value0;     // 键值1
    u8 key_value1;     // 键值2
};

struct rdec_platform_data {
    u8 enable;
    u8 num;     // rdec数量
    const struct rdec_device *rdec;
};

#define RDEC_PLATFORM_DATA_BEGIN(data) \
    static const struct rdec_platform_data data = {

#define RDEC_PLATFORM_DATA_END() \
    };

/*********************** rdec 初始化 ******************************/
int rdec_init(const struct rdec_platform_data *user_data);
s8 get_rdec_rdat(int i);

#endif
